package com.heng.library.yhhandlerdemo

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Example of a call to a native method
        findViewById<Button>(R.id.btnInit).setOnClickListener {
            initHandler()
        }
        findViewById<Button>(R.id.btnUnInit).setOnClickListener {
            quitHandler()
        }
        var id=0;
        findViewById<Button>(R.id.btnSendMessage).setOnClickListener {
            for(i in 0 until 100){
                sendMessage(id++,"你好")
            }

        }
    }

    external fun initHandler()
    external fun quitHandler()
    external fun sendMessage(what:Int,data:String)


    companion object {
        // Used to load the 'native-lib' library on application startup.
        init {
            System.loadLibrary("native-lib")
        }
    }
}